﻿using System;
using System.Collections.Generic;
using System.Text;
using Volo.Abp;

namespace mozhi.smarterp.Finance.Finances
{
    public class JournalNumberPrefix : AggregateRootBase<Guid>
    {
        public string Code { private set; get; }

        public string Name { private set; get; }

        public bool IsDefault { set; get; }

        private JournalNumberPrefix() { }

        public JournalNumberPrefix(Guid id, string code, string name, bool isDefault)
        {
            Id = id;
            Code = code;
            Name = name;
            IsDefault = isDefault;

            Validate();

        }


        private void Validate()
        {
            if (Code.IsNullOrEmpty())
                throw new UserFriendlyException("凭证字编号不能为空");

            if (Name.IsNullOrEmpty())
                throw new UserFriendlyException("凭证字名称不能为空");
        }

        public void Change(string code, string name, bool isDefault)
        {
            Code = code;
            Name = name;
            IsDefault = isDefault;

            Validate();
        }
    }
}
